/*
 * @lc app=leetcode.cn id=345 lang=javascript
 *
 * [345] 反转字符串中的元音字母
 */

// @lc code=start
/**
 * @param {string} s
 * @return {string}
 */
var reverseVowels = function(s) {
    s = s.split('')
    let point1 = 0
    let point2 = s.length - 1
    const testArr = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
    for (let index = 0; index < s.length; index++) {
        if (point2 <= point1) {
            break
        }
        const element1 = s[point1];
        const element2 = s[point2];
        if (testArr.includes(element1) && testArr.includes(element2)) {
            s[point2] = element1
            s[point1] = element2
            ++point1
            --point2
        } else {
            if (testArr.includes(element1)) {
                --point2
            } else {
                ++point1
            }
        }
    }
    return s.join('')
};
// @lc code=end

